#include "../comm.h"
class Solution {
public:
    int pivotIndex(vector<int>& nums) {
        // 使用并行计算的方法求和，相比于accumulate速度更快
        int sum = reduce(nums.begin(), nums.end(), 0);
        int now = 0;
        for (int i = 0; i < nums.size(); ++i)
        {
            sum -= nums[i];
            if (i) now += nums[i - 1];
            if (sum == now) return i;
        }
        return -1;
    }
};